package user.web.repository;

import domain.User;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Created by Administrator on 2017/11/26.
 */
@Repository
public class UserRepository {
    private ConcurrentMap<Long, User> repostory = new ConcurrentHashMap();
    private static final AtomicLong idGenerator = new AtomicLong(0);
    private static long id=0;
    public boolean save(User user) {
        user.setId(id++);
        User result = repostory.put(user.getId(), user);
        System.out.println(result);
        return result == null;
    }

    public Collection<User> findAll() {
        return repostory.values();
    }
}

